package com.yingjia.yingjiauniversity.retrofit.convert;


import com.yingjia.yingjiauniversity.json.manager.JsonManager;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

import okhttp3.RequestBody;
import retrofit2.Converter;


public class ObjectRequestBodyConverter implements Converter<Object, RequestBody> {
    protected Logger logger = LoggerFactory.getLogger(((Object) this).getClass());

    @Override
    public RequestBody convert(Object value) throws IOException {
        String jsonString = JsonManager.getInstance().getComponent().toJson(value, null, null, null);
        RequestBody body = RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"), jsonString);
        return body;
    }
}
